package com.hqd.ch03.v20.aop.framework.aspectj;

import com.hqd.ch03.v20.aop.Pointcut;
import com.hqd.ch03.v20.aop.PointcutAdvisor;
import com.hqd.ch03.v20.aopalliance.aop.Advice;
import com.hqd.ch03.v20.core.Ordered;

public class AspectJPointcutAdvisor implements PointcutAdvisor, Ordered {
    /**
     * 通知
     */
    private final AbstractAspectJAdvice advice;

    /**
     * 切点
     */
    private final Pointcut pointcut;

    private Integer order;


    public AspectJPointcutAdvisor(AbstractAspectJAdvice advice) {
        this.advice = advice;
        this.pointcut = advice.getPointcut();
    }

    @Override
    public int getOrder() {
        if (this.order != null) {
            return this.order;
        } else {
            return this.advice.getOrder();
        }
    }

    public void setOrder(int order) {
        this.order = order;
    }


    @Override
    public Advice getAdvice() {
        return this.advice;
    }

    @Override
    public Pointcut getPointcut() {
        return this.pointcut;
    }

    public String getAspectName() {
        return this.advice.getAspectName();
    }
}
